<template>
    <div class="info-attr-module">

        <div class="title">
            赛事信息
        </div>
        <div class="attr-data">
            <div class="item" v-if="record.team_name">
                <span>参与代表对队</span>
                <div>{{ record.team_name }}</div>
            </div>
            <div class="item">
                <span>领队</span>
                <div>{{ record.leader }}</div>
            </div>
        </div>
        <div class="title wt">
            赛事信息
        </div>
        <div class="attr-data">
            <div class="item">
                <span>参与赛事</span>
                <div>{{ matchInfo.matchName }}</div>
            </div>
            <div class="item">
                <span>参与赛项</span>
                <div>{{ record.item_name }}</div>
            </div>
            <div class="item">
                <span>参赛组别</span>
                <div>{{ record.group_name }}</div>
            </div>
            <div class="item">
                <span>参赛选手</span>
                <div>{{ record.real_name }}</div>
            </div>
            <div class="item" v-if="record.team_name">
                <span>队伍名称</span>
                <div>{{ record.team_name }}</div>
            </div>
            <div class="item">
                <span>指导老师</span>
                <div>{{ record.zdlsStr }}</div>
            </div>
            <div class="item">
                <span>比赛时间</span>
                <div>{{ matchInfo.matchDate }}</div>
            </div>
            <div class="item">
                <span>报名时间</span>
                <div>{{ record.create_date }}</div>
            </div>
        </div>
        <div class="title wt" v-if="record.score_open == 1">成绩信息</div>
        <div class="attr-data" v-if="record.score_open == 1">
            <div class="item" v-if="isShowScore(matchInfo.matchLevel, sysParams.isShowMatchScore)">
                <span>成绩</span>
                <div style="color: orange;" v-html="scoreResut.score ? scoreResut.score.replace('.', '″') : ''"></div>
            </div>
            <div class="item" v-if="isShowRanks(matchInfo.matchLevel, sysParams.isShowMatchRanks)">
              <span>名次</span>
              <div style="color: orange;" v-html="scoreResut.ranks"></div>
            </div>
            <div class="item" v-if="isShowGrade(matchInfo.matchLevel, sysParams.isShowMatchGrade)">
              <span>奖等</span>
              <div style="color: orange;" v-html="scoreResut.grade"></div>
            </div>
        </div>
        <div class="info-hint">
            <span>注：</span>
            <div>赛前请关注 参赛报名 > 报名记录 > 对应赛事赛项的参赛时间信息；<br />
                赛前请关注 参赛报名 > 报名记录 > 对应赛事赛项的抽签信息。</div>
        </div>
    </div>
</template>


<script lang="ts">

import { ref, defineComponent } from "vue";
import baseService from "@/service/baseService";

export default defineComponent({
    data() {
        return {
            status: null as any,
            typename: null as any, type: null as any,
            id: null as any,
            /**
             * 详情
             */
            record: {
                create_date: '',
                rise_file: '',
                rise_file_old: '',
                rise_times: '',
                rise_file_show: '',
                is_promiss: null as any,
                promiss_file: '',
                promiss_file_old: '',
                promiss_times: '',
                promiss_file_show: '',
                user_ids: '',
                classname: "创意类",
                group_name: "初中组",
                teachers: "姓名7",
                item_name: "团体花样表演",
                real_name: "王莉莉、张悦悦、宋婷婷",
                id: "1655117165470240769",
                typename: "团体赛",
                team_name: "214234",
                zdlsStr: '',
            },
            /**
             * 赛项
             */
            matchInfo: {
                matchName: '',
                matchLevel: '' as string,
                beginSignup: '',
                beginDate: '',
                matchDate: '',
                signupDate: '',
            },
            /**
             * 比赛成绩
             */
            scoreResut: {
                score: '',
                ranks: '',
                grade: ''
            },
            sysParams: {},
        }
    },
    mounted() {
        this.id = this.$route.query.id;
        this.type = this.$route.query.type;
        this.status = this.$route.query.status;
        this.typename = this.$route.query.typename;
        this.querySysParams();
        this.queryInfo();
        this.queryScore();
    },
    methods: {
       /**
        * 查询详情
        */
        queryInfo() {
         if (!this.id) {
           return;
         }
         baseService.get('/front/fast/match/matchRecordItem/info?myinfo=1&id=' + this.id).then(e => {
           this.record = e.data;
           //获取指导老师
           const zdls = this.record.teachers.split(",");
           if (zdls.length > 1) {
             this.record.zdlsStr = zdls[0];
             console.log(zdls[1]);
             for (let i = 0; i < zdls[0].length; i++) {
               this.record.teachers = zdls[i];
             }
           }
           this.queryMatch(e.data.match_id);
         })
       },
        /**
         * 查询赛项
         * @param id
         */
        queryMatch(id: string) {
            baseService.get('/front/spmatch/info/' + id).then(e => {
                console.log('==========')
                this.matchInfo = e.data;
            })
        },
        /**
         * 查询成绩
         */
        queryScore() {
            baseService.get('/front/spmatchItemTeam/queryScore?id=' + this.id).then(e => {
                this.scoreResut = e.data;
            })
        },

        querySysParams(){
            baseService.get('/front/spmatch/sysParams').then(e => {
                this.sysParams = e.data;
            })
        },

        isShowScore(matchLevel :string, isShowMatchScore :string){
            //国赛且开通显示成绩、省赛的显示成绩
            return (matchLevel=='1' && isShowMatchScore=='1') || matchLevel=='2';
        },

        isShowRanks(matchLevel :string, isShowMatchRanks :string){
            //国赛且开通显示成绩、省赛的显示成绩
            return (matchLevel=='1' && isShowMatchRanks=='1') || matchLevel=='2';
        },

        isShowGrade(matchLevel :string, isShowMatchGrade :string){
            //国赛且开通显示成绩、省赛的显示成绩
            return (matchLevel=='1' && isShowMatchGrade=='1') || matchLevel=='2';
        }


    }
});


</script>


<style lang="scss" scoped>
@import "./style.scss";
</style>
